﻿angular.module("app").factory('adeptData', function() {
  var adepts = [];

  function baseAdept(name, clan) {
    this.name = name;
    this.clan = clan;
    this.hp = 0;
    this.pp = 0;
    this.pp = 0;
    this.attack = 0;
    this.defense = 0;
    this.agility = 0;
    this.Power = [0, 0, 0, 0];
    this.Resistance = [0, 0, 0, 0];
    this.gold = 10;
    this.Upgrades = [null, null];
    adepts.push(this);
  };


  var issac = new baseAdept("Issac", "Venus");
  var felix = new baseAdept("Felix", "Venus");
  var mia = new baseAdept("Mia", "Mercury");
  var piers = new baseAdept("Piers", "Mercury");
  var garet = new baseAdept("Garet", "Mars");
  var jenna = new baseAdept("Jenna", "Mars");
  var ivan = new baseAdept("Ivan", "Jupiter");
  var sheba = new baseAdept("Sheba", "Jupiter");

  var currentAdepts = [issac, garet, mia, ivan];
  var backupAdepts = [felix, piers, jenna, sheba];

  return {
    getIssac: function() {
      return issac;
    }, //getIssac
    getCurrent: function() {
      return currentAdepts;
    },
    getBackup: function() {
      return backupAdepts;
    },
    getAll: function() {
      return adepts;
    },
    replaceAdept: function(curAdept, newAdept) {
      var cp = currentAdepts.indexOf(curAdept);
      var bp = backupAdepts.indexOf(newAdept);
      if (cp >= 0 && bp > 0) {
        currentAdepts[cp] = newAdept;
        backupAdepts[bp] = curAdept;
        alert("Replaced " + curAdept.name + " with " + newAdept.name);
      }
    } //replaceAdept

  };
});